package com.wms.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wms.bean.PageBean;
import com.wms.dto.SuserUpVo;
import com.wms.entity.Suser;
import com.wms.mapper.SuserMapper;
import com.wms.service.SuserService;
import com.wms.dto.SuserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class SuserServiceImpl implements SuserService {

    @Autowired
    private SuserMapper suserMapper;

    /**
     *
     * @param suserVo 查询条件
     * @return
     */
    @Override
    public PageBean<List<Suser>> queryPageAndContion(SuserVo suserVo) {
        // 设置分页参数
        PageHelper.startPage(suserVo.getPage(), suserVo.getPageSize());
        // 执行查询
        List<Suser> list = suserMapper.queryPageAndContion(suserVo);
        // 封装分页结果
        PageInfo<Suser> pageInfo = new PageInfo<>(list);
        return new PageBean<List<Suser>>(suserVo.getPage(), suserVo.getPageSize(), pageInfo.getTotal(), pageInfo.getList());
    }

    @Override
    public int insert(SuserUpVo suserUpVo) {
        return suserMapper.insert(suserUpVo);
    }

    @Override
    public int update(SuserUpVo suserUpVo) {
        return suserMapper.update(suserUpVo);
    }

    @Override
    public int deleteById(int id) {
        return suserMapper.deleteById(id);
    }

    @Override
    public int updateStatus(int id) {
        return suserMapper.updateStatus(id);
    }

    @Override
    public int updatePassword(int id) {
        return suserMapper.updatePassword(id);
    }

}